#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#include <errno.h>
#include <memory.h>

#include "pthread_cond.h"

void * thr_fn(void * arg)
{
	struct condition_var *cond = (struct condition_var *)arg;
	condition_var_wait(cond);
	printf("thread wait succeed\r\n");
	return NULL;
}


int main()
{
	struct condition_var cond;
	memset(&cond, 0, sizeof(struct condition_var));
	condition_var_init(&cond);
    pthread_t thread1;
    
    if (0 != pthread_create(&thread1, NULL, thr_fn, &cond))
    {
        printf("error when create pthread,%d\n", errno);
        return 1;
    }
    sleep(1);

	condition_var_complete(&cond);
    pthread_join(thread1, NULL);
	condition_var_deinit(&cond);
    return 0;
}
